<%@page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<style type="text/css">
<%@include file="../stylesheets/progresbar.css"%>
 <%@ include file="../stylesheets/main.css"%> 
<%@ include file="../stylesheets/header.css"%>
<%@ include file="../stylesheets/footer.css"%>
 <%@ include file="../stylesheets/indexContent.css"%>
<%@ include file="../stylesheets/carousel.css"%> 
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script language="JavaScript">
	function productDetail(id) {
		document.forms['productDetails'].operation.value = 'productDetails';
		document.forms['productDetails'].selectedId.value = id;
		document.forms['productDetails'].submit();
		return false;
	}
	function remove(id) {
		document.forms['productRemove'].operation.value = 'productRemove';
		document.forms['productRemove'].selectedId.value = id;
		document.forms['productRemove'].submit();
		return false;
	}
	function startProduction(id) {
/* 		if (document.forms['start'].amount.value == ""){
			alert("Wprowadź liczbę produktow !");
		}else{ */
		var am = prompt('Podaj Liczbę do wyprodukowania', '200');
		 if(am==""){
			 alert('Nieprawidłowa wartość');
			 return false;
		 }
		 if (am){
				document.forms['start'].amount.value = am;
				document.forms['start'].operation.value = 'start';
				document.forms['start'].selectedId.value = id;
				document.forms['start'].submit();	
				return false;
		 }

	}
</script>



<title>Produkty</title>
</head>

<body>
	<div id="left-column-outer">
		<div id="left-column"></div>
	</div>
	<div id="center-column">
		<div class="CenteredContainer">
			<img id="background_noresize" alt="background_noresize"
				src="<%=request.getContextPath()%>/img/background.jpg" />
			<%@ include file="header.jsp"%>
			<div class="ContentShade">
			
			
			


		<div style="height:400px; overflow:auto">	
				<table>
					<tr>
						<!-- <th>Id</th> -->
						<th>Nazwa</th>
						<th>Producent</th>
						<th>Typ</th>
						<th>Opakowanie</th>
						<th>Zawartość alk.</th>
						<th>Cena</th>
						<th>Pojemność</th>
					</tr>
					

					<c:forEach items="${productList}" var="p" varStatus="loop">
						<tr align="center">
							<%--  <td width="300">${p.productId }</td> --%>
							<td>${p.name }</td>
							<td>${p.manufacturer }</td>
							<td>${p.type }</td>
							<td>${p.bundle }</td>
							<td>${p.voltage }</td>
							<td>${p.price }</td>
							<td>${p.capacity }</td>
							<td>
								<form name="productDetails" action="products"
									method="post">
									<INPUT TYPE="BUTTON" value="Szczegóły"
										ONCLICK="productDetail(${p.id})"> 
										<input type="hidden" name="operation"> 
										<input type="hidden" name="selectedId">
								</form>
								<td align="left">
								<form name="productRemove" action="products"
									method="post">
									<INPUT TYPE="BUTTON" value="Usuń"
										ONCLICK="remove(${p.id})"> 
										<input type="hidden" name="operation"> 
										<input type="hidden" name="selectedId">
								</form></td>
								<td align="left">
								<form name="start" action="products" method="post">
									
<!-- 										<input size="10" type="number" name="amount">  -->
										<INPUT TYPE="BUTTON" value="Produkuj"
										ONCLICK="startProduction(${p.id})"> 
										<input type="hidden" name="operation"> 
										<input type="hidden" name="selectedId">
										<input type="hidden" name="amount">
								</form></td>
								
							</td>
	
						</tr>
					</c:forEach>
					
					<tr>
							<td></td><td></td><td></td><td></td><td></td><td></td>
							<td></td><td></td><td></td>
								<td>
										</td></tr>
				</table>

</div><a align="right" href="addproduct"><INPUT  TYPE="BUTTON" value="Dodaj Produkt"> 
									</a>
				<%@ include file="footer.jsp"%>
			</div>
		</div>
	</div>
	<div id="right-column-outer">
		<div id="right-column"></div>
	</div>

</body>